datum
	var/uid		//universal ID

	proc/GenerateTag(override)
		if(override)
			tag = override
			return tag
		var/x = 1
		while(findtext( copytext("[type]",x+1,0), "/"))
			x = findtext( copytext("[type]",x+1,0), "/")
		tag = "[copytext("[type]",x+1,0)]_[uid]"
		return tag

universe
/*"Space is big. Really big. You just won't believe how vastly hugely mindbogglingly big it is.
I mean you may think it's a long way down the road to the chemist, but that's just peanuts to space."*/
	proc
		Gravity(celestial/source, celestial/target)
			var/dist = max(0.5,source.coord.DistanceTo(target.coord))
			return G()*((source.mass*target.mass)/(dist*dist))

		G()
			return 6.6742e-11

		ConvertMetric(input, output, format=0)
			var/_ivalue		= text2num(input)
			var/_imetric	= copytext(input, lentext("[_ivalue]")+1,0)
			var/_ometric	= output
			var/Query/Qi = GDBH.NewQuery("select `metric`,`value`, `type` from `finalfrontiers`.`metrics` where `metric` = '[_imetric]'")
			var/Query/Qo = GDBH.NewQuery("select `metric`,`value`, `type` from `finalfrontiers`.`metrics` where `metric` = '[_ometric]'")
			Qi.Execute()
			Qo.Execute()
			if(!Qi.RowCount()) CRASH("Input Metric Invalid: [_imetric]")
			if(!Qo.RowCount()) CRASH("Input Metric Invalid: [_ometric]")
			Qi.NextRow()
			Qo.NextRow()
			var/list/i_row = Qi.GetRowData()
			var/list/o_row = Qo.GetRowData()
			if(i_row["type"] != o_row["type"]) CRASH("ERROR: TRYING TO CONVERT [i_row["type"]] TO [o_row["type"]]")

			var/ratio = text2num(i_row["value"]) / text2num(o_row["value"])
			if(format) return "[ratio*_ivalue][_ometric]"
			return ratio*_ivalue



var/DBHandler/GDBH = new("localhost",3306,"finalfrontiers","root","")

galaxy
	var
		universe/parent



celestial
	parent_type = /obj
	var
		galaxy/parent

		size		//rough diameter, in kilometers
		mass		//rough mass, in kilograms
		coordinate/coord
		scale_dist = "m"
		scale_mass = "kg"

	New()
		. = ..()
		coord = new(0,0,0)
		return .

	proc
		SetMass(m as num)
			mass = m
			return mass
		GetMass(format as num)
			if(format) return "[mass][scale_mass]"
			return mass

		SetCoord(i,j,k)
			coord = new(i,j,k)

		GetCoord()
			return coord

		AngleTo(celestial/c)
			var/coordinate/co = src.GetCoord()
			return co.AngleTo(c.GetCoord())

/*Now, this may take some explaining. A celestial is any object one may find floating in space, for any reason.
A comet. A planet. A moon. A star. All these are celestials. The celestial datum covers all the common aspects of
such objects (size, mass, inertia, temperature, trajectory, etc). Further objects will use this as a base object
and build from there*/

nebula
	parent_type = /celestial

star
	parent_type = /celestial

planet
	parent_type = /celestial

moon
	parent_type = /celestial

comet
	parent_type = /celestial

asteroid
	parent_type = /celestial


domain
subdomain
sector
subsector
system

mob/verb/test()
	var/planet/planet = new()
	planet.uid = 1
	planet.GenerateTag()
	world<<planet.tag